package com.spring.boot.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
@ConditionalOnProperty(prefix = "condition.config", name = "enable", havingValue = "true")
public class ConditionController {

    @Value("${random.str}")
    private String randomStr;

//    /**
//     * 命令行参数添加 --spring.application.json={\"k1\":\"v1\"}
//     */
//    @Value("${k1}")
//    private String k1;
//
//    @Value("${condition.config.msg}")
//    private String msg;

    @PostConstruct
    public void init(){
//        System.out.println("condition init. msg = " + msg);
    }

}
